/*
package com.lwq.im.chartdemo.util;

import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

@Component
@Aspect
@Slf4j
public class AspectLog {

    @Pointcut("@annotation(org.springframework.web.bind.annotation.RequestMapping) || @annotation(org.springframework.web.bind.annotation.GetMapping) " +
            "|| @annotation(org.springframework.web.bind.annotation.DeleteMapping) || @annotation(org.springframework.web.bind.annotation.PostMapping) " +
            "|| @annotation(org.springframework.web.bind.annotation.PutMapping) || @annotation(org.springframework.web.bind.annotation.PatchMapping)")
    public void enableLog(){}

    @Around("enableLog()")
    public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
        long startTime = System.currentTimeMillis();
        String serialNo = IdUtil.simpleUUID();
        ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        HttpServletRequest request = servletRequestAttributes.getRequest();
        String requestURI = request.getRequestURI();
        Object[] args = joinPoint.getArgs();
        MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
        String[] parameterNames = methodSignature.getParameterNames();
        Map<String, Object> logParams = new HashMap<>();
        if (ArrayUtil.isNotEmpty(args)){
            int length = args.length;
            for (int i = 0; i < length; i++){
                // 记录的日志排除文件排除文件
                if (args[i] instanceof MultipartFile || args[i] instanceof HttpServletRequest || args[i] instanceof HttpServletResponse){
                    continue;
                }
                String parameterName = parameterNames[i];
                logParams.put(parameterName, args[i]);
            }
        }
        log.info("serialNo={}，请求={}，开始执行。入参={}", serialNo,requestURI, JSON.toJSONString(logParams));
        Object result = joinPoint.proceed(args);
        log.info("serialNo={}，请求={}，执行完成。耗时={}，返回结果={}", serialNo,requestURI, System.currentTimeMillis() - startTime, JSON.toJSONString(result));
        return result;
    }
}
*/
